import request from "@/util/request"
import { API_SITE, API_PREFIX } from "./_prefix"

/**
 * 获取全部用户邮箱
 */
export const getAllUserMailBox = (userId) => {
    //TODO
    return request(`${API_SITE}${API_PREFIX}/${userId}/mailbox`)
}

/**
 * 根据邮箱ID获取用户
 */
export const getUserMailBoxById = (userId, mailBoxId) => {
    return request(`${API_SITE}${API_PREFIX}/${userId}/mailbox/${mailBoxId}`)
}

/**
 * 更新邮箱信息(待修改body传参数据结构)
 */
export const updateUserMailBox = (userId,mailBoxId,UserMailBoxDTO) => {
    return request(`${API_SITE}${API_PREFIX}/${userId}/mailbox/${mailBoxId}`,{
        method: "POST",
        body: {
            UserMailBoxDTO,
        }
    })
}

/**
 * 新建用户信箱
 */
export const createUserMailBox = (userId,email,password,type) => {
    return request(`${API_SITE}${API_PREFIX}/${userId}/mailbox`,{
        method: "POST",
        body: {
            email: email,
            psd: password,
            type: type,
        }
    })
}

/**
 * 删除用户信箱
 */
export const deleteUserMailBox = (userId, mailBoxId) => {
    return request(`${API_SITE}${API_PREFIX}/${userId}/mailbox/${mailBoxId}/delete`,{
        method: "POST"
    })
}